home *** CD-ROM | disk | FTP | other *** search
/ The Netter Presenter: Ur…ion in Overactive Bladder / The Netter Presenter: Urinary System - Structure & Function in Overactive Bladder.iso / mac / UrinarySystem.app / Contents / Main.dxr / Internal_15_DataBase Management.ls < prev    next >
Encoding:
Text File  |  2005-01-18  |  3.3 KB  |  112 lines

  1. global gDataBase, gTitleTable, gLabelTable, gNumberTitleTable, gDomain, gListObject
  2.  
  3. on LoadDB
  4.   OpenDatabaseReadWrite()
  5.   DisplayErrorStatus()
  6. end
  7.  
  8. on OpenDatabaseReadWrite
  9.   if objectp(gDataBase) then
  10.     gDataBase = 0
  11.   end if
  12.   if objectp(gTitleTable) then
  13.     gTitleTable = 0
  14.   end if
  15.   if objectp(gLabelTable) then
  16.     gLabelTable = 0
  17.   end if
  18.   if objectp(gNumberTitleTable) then
  19.     gNumberTitleTable = 0
  20.   end if
  21.   gDataBase = new(xtra("V12Dbe"), the moviePath & "UrinarySystemDB.V12", "ReadWrite", EMPTY)
  22.   gTitleTable = new(xtra("V12Table"), mGetRef(gDataBase), "Title_Words")
  23.   gLabelTable = new(xtra("V12Table"), mGetRef(gDataBase), "Label_Words")
  24.   gNumberTitleTable = new(xtra("V12Table"), mGetRef(gDataBase), "Number_Title")
  25. end
  26.  
  27. on FindAll tableInstance, fieldname, TheOperator, findWord
  28.   if objectp(tableInstance) then
  29.     mSetIndex(tableInstance, fieldname & "Ndx")
  30.     mSetCriteria(tableInstance, fieldname, TheOperator, findWord)
  31.     mSelect(tableInstance)
  32.     n = mSelectCount(tableInstance)
  33.     value(gListObject).pltnnumberlist = mGetSelection(tableInstance, "LIST", mGetPosition(tableInstance), n)
  34.     accumulator = []
  35.     if value(gListObject).pltnnumberlist <> [] then
  36.       repeat with rawListNum = 1 to value(gListObject).pltnnumberlist.count
  37.         tmpList = value(getAt(getAt(value(gListObject).pltnnumberlist, rawListNum), 2))
  38.         if tmpList <> VOID then
  39.           repeat with listnum = 1 to tmpList.count
  40.             if accumulator = [] then
  41.               append(accumulator, getAt(tmpList, listnum))
  42.               next repeat
  43.             end if
  44.             if getOne(accumulator, getAt(tmpList, listnum)) = 0 then
  45.               append(accumulator, getAt(tmpList, listnum))
  46.             end if
  47.           end repeat
  48.         end if
  49.       end repeat
  50.     end if
  51.     value(gListObject).pltnnumberlist = duplicate(accumulator)
  52.     sort(value(gListObject).pltnnumberlist)
  53.   else
  54.     put "Open database first..."
  55.   end if
  56. end
  57.  
  58. on PerformSimpleSearch TheOperator, findWord, Domain
  59.   value(gListObject).pltnnumberlist = []
  60.   if gDomain = "Titles" then
  61.     FindAll(gTitleTable, "Title_Word", TheOperator, findWord)
  62.     return value(gListObject).pltnnumberlist
  63.   end if
  64.   if gDomain = "Labels" then
  65.     FindAll(gLabelTable, "Label_Word", TheOperator, findWord)
  66.     return value(gListObject).pltnnumberlist
  67.   end if
  68. end
  69.  
  70. on FindTitle findNumber
  71.   if objectp(gNumberTitleTable) then
  72.     mSetIndex(gNumberTitleTable, "Image_Number" & "Ndx")
  73.     mSetCriteria(gNumberTitleTable, "Image_Number", "=", findNumber)
  74.     mSelect(gNumberTitleTable)
  75.     n = mSelectCount(gNumberTitleTable)
  76.     return mGetSelection(gNumberTitleTable, "LITERAL", 1, mSelectCount(gNumberTitleTable), TAB, RETURN, "Image_Title")
  77.   end if
  78. end
  79.  
  80. on JoinLists list1, list2
  81.   newList = duplicate(list1)
  82.   repeat with x in list2
  83.     if getOne(newList, x) = 0 then
  84.       add(newList, x)
  85.     end if
  86.   end repeat
  87.   return newList
  88. end
  89.  
  90. on IntersectLists list1, list2
  91.   if ilk(list1, #linearList) and ilk(list2, #linearList) then
  92.     newList = []
  93.     repeat with x in list2
  94.       if getOne(list1, x) <> 0 then
  95.         append(newList, x)
  96.       end if
  97.     end repeat
  98.   else
  99.     alert("Both lists need to be of LINEAR type to join.")
  100.   end if
  101.   return newList
  102. end
  103.  
  104. on DisplayErrorStatus
  105.   errCode = mStatus(xtra("V12dbe"))
  106.   if errCode <> 0 then
  107.     alert(mError(xtra("V12dbe")))
  108.   else
  109.     put "no errors detected"
  110.   end if
  111. end
  112.